home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 1993 May
/
Info-Mac_II_May_1993.to_.sit
/
Info-Mac II (May 1993).toast
/
Unix
/
Info-mac-browser.txt
< prev
next >
Wrap
Internet Message Format
|
1993-03-27
|
2KB
From: Craig Nevill-Manning <cgn@kauri.cs.waikato.ac.nz>
Date: Thu, 11 Feb 93 11:58:59 -0800
Subject: Browsing digests for recent uploads
I wrote this quick Unix program for browsing info-mac digests. I try to keep
up with the new uploads to sumex, but it's a tedious, repetitive process to
actually download the stuff I want. This C program scans a digest (or several)
in a file or files given on the command line for the [*] denoting an upload
notice, and prints out the description. Type y if you want to download it, and
it adds the path and name to a file called "download". Typing n just continues
to the next message, and q quits the program. I then rearrange the file in
emacs, inserting cd and get commands, and paste it into an ftp session.
Hope it's useful to someone! Remember, it was only a half-hour hack; feel free
to improve on it.
Compile with cc -o skim skim.c -lcurses -ltermcap
or take out the curses stuff if you don't have it.
---
Craig Nevill-Manning, e-mail: cgn@waikato.ac.nz
Department of Computer Science, phone: +64 7 838 4021 (work)
University of Waikato, +64 7 838 4232 (home)
Private Bag 3105,
Hamilton,
New Zealand.
skim.c follows:
#include <stdio.h>
#include <curses.h>
FILE *download;
main(argc, argv)
int argc;
char **argv;
{
int i;
initscr();
cbreak();
download = fopen("download", "a");
for (i = 1; i < argc; i ++)
skim(argv[i]);
nocbreak();
endwin();
}
skim(filename)
char *filename;
{
FILE *f;
char s[1000], name[1000];
int ch, line;
f = fopen(filename, "r");
if (f) {
while (!feof(f)) {
do {
fgets(s, 1000, f);
} while (strncmp(s, "Subject: [*]", 12) != 0 && !feof(f));
line = 0;
name[0] = 0;
clear();
refresh();
puts(filename);
while (!feof(f)) {
if (line ++ < LINES - 4)
printf("%s", s);
fgets(s, 1000, f);
if (strncmp(s, "[Archived as", 12) == 0) {
strcpy(name, &s[13]);
break;
}
}
printf("%s", s);
if (name[0]) {
printf("Get this? (y/n)");
do
ch = getchar();
while (ch != 'y' && ch != 'n' && ch != 'q');
if (ch == 'y') {
int i;
for (i = strlen(name); i > 0 && name[i] != ';'; i --)
;
name[i] = 0;
fprintf(download, "%s\n", name);
}
else if (ch == 'q') {
fclose(download);
nocbreak();
endwin();
exit(0);
}
}
}
fclose(f);
}
}